<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <!--      end-->
      <div class="tab-body">
        <div class="tab-box">
          <el-radio-group v-model="downloadOption.type" size="small" @change="changeFn()">
            <el-radio-button :label="0">申请中({{ tabNumer[0] }})</el-radio-button>
            <el-radio-button :label="1">已领用({{ tabNumer[1] }})</el-radio-button>
          </el-radio-group>
        </div>
        <div class="tab-box-list" v-if="downloadOption.type==1">
          <el-date-picker
              v-model="valueText"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              size="small"
              :picker-options="pickerOptions1"
              class="mr-10"
              @change="changeTime">
          </el-date-picker>
          <downexcel type="materielLending" :option="downloadOption"></downexcel>
          <downexcel type="materielLendingcount" :option="downloadOption"></downexcel>
        </div>
      </div>
      <apply v-if="downloadOption.type==0" ref="backBookChange" @getNewNumber="getNewNumber"
             :searchForm="searchForm"></apply>
      <applyEnd v-if="downloadOption.type==1" ref="returntedChange" @getNewNumber="getNewNumber"
                :searchForm="searchForm"></applyEnd>
    </div>
  </div>
</template>

<script>
import apply from "./lead/apply";
import applyEnd from "./lead/applyEnd";

export default {
  components: {
    apply,
    applyEnd
  },
  data() {
    return {
      tabNumer: [],
      pickerOptions1: {
        disabledDate(time) {
          return time.getTime() > Date.now()//  - 8.64e7
        }
      },
      valueText: [],
      // 搜索组件
      searchForm: {},
      downloadOption: {
        type: 0,
        start_time: '',
        end_time: ''
      }
    }
  },
  created() {

  },
  methods: {
    searchFn(option) {
      console.log(option)
      this.searchForm = JSON.parse(JSON.stringify(option))
    },
    changeTime() {
      console.log('valueText:', this.valueText)
      if (this.valueText) {
        this.downloadOption.start_time = this.valueText[0]
        this.downloadOption.end_time = this.valueText[1]
      } else {
        this.downloadOption.start_time = ''
        this.downloadOption.end_time = ''
      }
    },
    changeFn() {
      this.searchForm = JSON.parse(JSON.stringify(this.searchForm))
      // this.searchForm = {};
      // this.$refs.searchModleFn.refreshFn();
    },
    // 跟新数量
    getNewNumber(option) {
      this.tabNumer = JSON.parse(JSON.stringify(option))
    }
  },
  mounted() {
  }
}
</script>
<style>
.tab-body {
  display: flex;
  align-items: center;
}

.tab-box {
  flex: 1;
}
</style>
